
================================================================================
CONTENTS
================================================================================

1. CODE FILES (in code/ folder):
   - 0_main_create_firm_data.do    : Master file that runs the replication
   - prep_deflators.do             : Creates deflator files from raw GSO price data
   - create_firm_data.do           : Creates firm_data.dta from GSO and trade data

2. RAW DATA FILES (to be placed in raw/ folder):
   - gso.dta                       : GSO census firm panel data
   - import_firms.dta              : Firm-level import aggregates
   - export_firms.dta              : Firm-level export aggregates

3. RAW PRICE DATA FILES (to be placed in raw/prices/ folder):
   - sector_correspondence.xlsx
   - Annual average CPI (Previous year = 100) [CSV]
   - export_price_index_2023.xlsx
   - import_price_index_2023.xlsx
   - Producer price index for agriculture, forestry and fishing (Year 2010 = 100) by Items and Year [CSV]
   - Producer price index for industry (Year 2010 = 100) by Industrial products and Year [CSV]
   - Producer price index for services (Year 2010 = 100) by Items and Year [CSV]

   Download from: https://www.gso.gov.vn/en/prices/

4. OUTPUT FILES:
   - firm_data.dta                 : Final replication dataset
   - _sector_correspondence.dta    : Created by prep_deflators.do
   - _cpi.dta                      : Created by prep_deflators.do
   - _expimp.dta                   : Created by prep_deflators.do
   - _ppi.dta                      : Created by prep_deflators.do
   - _exchange_rate.dta            : Created by prep_deflators.do


================================================================================
VARIABLES IN firm_data.dta
================================================================================

IDENTIFIERS:
  id                  : Numeric firm panel ID
  taxid               : 13-digit tax ID (taxid1-taxid2)
  taxid1              : 10-digit tax ID
  taxid2              : 3-digit establishment code
  year                : Year

SECTOR CLASSIFICATION:
  sector_group        : Broad sector groups (Agriculture, Manufacturing, Services, etc.)
  sector              : 2-digit VSIC sector code
  vsic_2digit         : 2-digit VSIC code (string)
  vsic_3digit         : 3-digit VSIC code
  vsic_4digit         : 4-digit VSIC code

LOCATION:
  province_code       : Province code
  district_code       : District code
  commune_code        : Commune code

FIRM CHARACTERISTICS:
  year_start          : Year of establishment
  age                 : Firm age (years)
  status              : Firm status
  fdi                 : FDI indicator (0=Domestic, 1=FDI)
  size                : Firm size (1=SME <100 employees, 2=Large ≥100)

FINANCIAL VARIABLES (ORIGINAL, MILLION VND):
  employment_o        : Number of employees
  salaries_and_bonuses_o : Total salaries and bonuses
  revenue_o           : Total revenue
  cogs_o              : Cost of goods sold
  interm_inputs_o     : Intermediate inputs
  va_o                : Value added

TRADE VARIABLES:
  importer            : Importer dummy (0/1)
  import_total        : Total imports (Million VND, deflated)
  import_share_rev    : Imports as % of revenue
  exporter            : Exporter dummy (0/1)
  export_total        : Total exports (Million VND, deflated)
  export_share        : Exports as % of revenue

DEFLATORS:
  ppi_sector          : PPI sector mapping
  cpi_deflator        : CPI deflator (base year 2014)
  ppi_deflator        : PPI deflator (base year 2014)
  ppi_deflator_2010   : PPI deflator (base year 2010)
  exp_deflator        : Export price deflator (base year 2014)
  imp_deflator        : Import price deflator (base year 2014)


================================================================================
INSTRUCTIONS FOR REPLICATION
================================================================================

STEP 1: PREPARE RAW DATA FILES
-------------------------------

A. Core firm and trade data files (in raw/ folder):
   1. gso.dta - Must contain:
      - year, taxid1, taxid2
      - vsic_4digit, vsic_3digit, vsic_2digit
      - province_code, district_code, commune_code
      - year_start, status, fdi_share
      - legal_form_2021_2022, legal_form_2020, legal_form_2012_2019
      - employment_o, salaries_and_bonuses_o, revenue_o, cogs_o

      Note: interm_inputs_o and va_o will be constructed by the code

   2. import_firms.dta - Must contain:
      - taxid1, taxid2, year
      - import_total

   3. export_firms.dta - Must contain:
      - taxid1, taxid2, year
      - export_total

B. Raw price data files (in raw/prices/ folder):
   Downloaded from https://www.gso.gov.vn/en/prices/
   

   - sector_correspondence.xlsx (mapping VSIC sectors to PPI sectors)
   - Annual average CPI (Previous year = 100) [CSV]
   - export_price_index_2023.xlsx
   - import_price_index_2023.xlsx
   - Producer price index for agriculture, forestry and fishing (Year 2010 = 100) by Items and Year [CSV]
   - Producer price index for industry (Year 2010 = 100) by Industrial products and Year [CSV]
   - Producer price index for services (Year 2010 = 100) by Items and Year [CSV]

 

STEP 2: RUN REPLICATION
------------------------

In Stata, cd to the VES_Replication/ folder and run the master script.
No path editing is needed — all paths resolve automatically from the working directory.

  cd "path/to/Replication/Code/VES_Replication"
  do "code/0_main_create_firm_data.do"

The code will:
  a) Create deflator files from raw GSO price data
  b) Create firm_data.dta from GSO census and trade data
  c) Generate summary statistics
  d) Save a log file (replication_log.txt)


================================================================================
DATA SOURCES
================================================================================

1. GSO (General Statistics Office) Vietnam Enterprise Census (2016-2022)
   - Source: 01_code/1.1.*_prep_gso_*.do

2. Vietnam Customs Department export/import transaction data
   - Source: 01_code/1.3.*_prep_customs*.do

3. Vietnam General Statistics Office price indices
   - Consumer Price Index (CPI)
   - Producer Price Index (PPI)
   - Export Price Index
   - Import Price Index
   - Source: https://www.gso.gov.vn/en/prices/
   - Created by: code/prep_deflators.do

4. Exchange rate data
   - Source: World Bank Open Data API
   - Retrieved by: code/prep_deflators.do


